<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        let arr = [1,2,3]
        let person = {name: "张三"}


        /* 浅拷贝：变量名都指向同一个对象 */
        arr[0] = 100 //这里修改arr[1]的值，下面打印arr2[1]的值会跟着改变
        let arr1 = arr
        console.log(arr1[0]) // arr2[1]的值也会变成100

        let person2 = person
        person.name = "小黑" // 这里修改person的name，下面打印person2的name也会变
        console.log(person2.name)



        /* 深拷贝就是完完全全产生一个新的对象 */
        let arr3 = [...arr] // 使用结构表达式产生新的对象
        arr[1] = 100
        console.log(arr[1]) // arr[1]的值改变了，下面不会影响arr3[1]的值
        console.log(arr3[1])

        // let person3 = {...person}
        let person3 = JSON.parse(JSON.stringify(person))
        person.name = "小明"
        console.log(person.name)
        console.log(person3.name)





    </script>
</head>
<body>
    
</body>
</html>